<?php
class AppModel extends Model {
	
	/**
	 * @name infoFile
	 * @param int $id
	 * @param stirng $filePath : dirname in folder webroot
	 * @return array: info about this file
	 * @tutorial get information file
	 */
	function infoFile($id = null, $filePath = 'files')
    {
    	$result = array();
    	if (!$id)
    	{
    		return $result;
    	}
    	
    	$this->recursive = -1;
    	$data = $this->findById($id);
    	if (isset($data[$this->name]))
    	{
    		$file = new File(APP.WEBROOT_DIR.DS.$filePath.DS.$data[$this->name]['source']);
    		$result = $file->info();
    		$result['last_changed'] = $file->lastChange();
    		$result['size'] = $file->size();
    	} 
    	
    	return $result;
    }
}
?>